package com.aaa.member.controller;

import com.aaa.common.constants.ExceptionConstant;
import com.aaa.common.constants.ReturnCode;
import com.aaa.common.util.Result;
import com.aaa.member.entity.AccountStatement;
import com.aaa.member.service.AccountStatementService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AccountStatement)表控制层
 *
 * @author chenhao
 * @since 2020-11-17 22:50:09
 */
@RestController
@RequestMapping("accountStatement")
@ApiOperation("账号流水")
public class AccountStatementController {
    /**
     * 服务对象
     */
    @Resource
    private AccountStatementService accountStatementService;


    /**
     * 收入记录统计
     * @param yearMonth
     * @return
     */
    @ApiOperation("收入记录统计")
    @GetMapping("incomeRecord")
    public Result incomeRecordTotal(@ApiParam("年月")@RequestParam("yearMonth") String yearMonth) {
        return accountStatementService.incomeRecordTotal(yearMonth);
    }
    /**
     * 进行充值
     * @param accountStatement
     * @return
     */
    @ApiOperation("账号充值")
    @PostMapping("addmoney")
    public Result addmoney(@RequestBody AccountStatement accountStatement) {

        return accountStatementService.addAccBlance (accountStatement);
    }

    /**
     * 通过客户id查询相关明细信息
     * @return
     */
    @GetMapping("selectByClientId")
    public Result selectByClientId(Integer clientId) {
        return new Result<>(ReturnCode.SUCCESS.getCode(), ReturnCode.SUCCESS.getMsg(),
                accountStatementService.selectByClientId (clientId));
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @GetMapping("selectAll")
    public List<AccountStatement> queryAllByLimit(int offset, int limit) {
        return this.accountStatementService.queryAllByLimit (offset, limit);
    }





    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @DeleteMapping("deleteById")
    public boolean deleteById(Integer id) {
        return this.accountStatementService.deleteById (id);
    }
}